#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
#include<stdbool.h>

typedef int TreeDataType;
typedef struct Tree
{
	TreeDataType val;
	struct Tree* left;
	struct Tree* right;
}Tree;

Tree* TreeNode(TreeDataType x)
{
	Tree* newnode = (Tree*)malloc(sizeof(Tree));
	if (newnode == NULL)
	{
		perror("malloc fail");
		exit(-1);
	}
	newnode->val = x;
	newnode->left = newnode->right = NULL;

	return newnode;
}

Tree* CreateTree()
{
	Tree* n1 = TreeNode(0);

	return n1;
}

int val = 0;
bool isUnivalTree(Tree* root) {
	static int i = 1;
	if (i)
		val = root->val;
	i = 0;

	if (root == NULL)
		return true;
	if (root->val != val)
		return false;
	return isUnivalTree(root->left) && isUnivalTree(root->right);
}

int main()
{
	Tree* root = CreateTree();
	printf("%d\n", isUnivalTree(root));
	return 0;
}